import java.awt.Image;

import javax.swing.ImageIcon;

public class Hero extends liikuvObjekt {
	private Image[] heroImage = new Image[16];
	private int width;
	private int height;
	private int state=0;

	public Hero(int x, int y, int yKiirus, int xKiirus) {
		super(x, y, yKiirus, xKiirus);
		// http://kirbyandluigi.smackjeeves.com/comics/766583/marios-sprites/
		for (int i = 0; i<8;i++){
			ImageIcon ii = new ImageIcon("Images/runL_"+(i+1)+".png");
			heroImage[i+8] = ii.getImage();
		}
		
		for (int i = 0; i<8;i++){
			ImageIcon ii = new ImageIcon("Images/runR_"+(i+1)+".png");
			heroImage[i] = ii.getImage();
		}
		
	    width = 21;
	    height = 32;
	}

	public Image getHeroImage() {
		if (state==7){
			state=0;
		}
		else{
			state++;
		}
		
		if(this.getXkiirus()>0){
			return heroImage[state];
		}
		else{
			return heroImage[state+8];
		}
		
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

}
